/**
 * Copyright (c) 2005-2012 springside.org.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package spring.data.jpa.repository.support;

import java.io.Serializable;

public class SearchFilter implements Serializable {

    private static final long serialVersionUID = -4504863806039584280L;

    public enum Operator {
		EQ("EQ", "="), LIKE("LIKE", "like"), GT("GT", ">"), LT("LT", "<"), GTE("GTE", ">="), LTE("LTE", "<="), NOT(
				"NOT", "<>"), IN("IN", "in"), ISNULL("ISNULL", "is null"), ISNOTNULL("ISNOTNULL", "is not null");
		private String code;

		private String nativeCode;

		Operator(String code, String nativeCode) {
			this.code = code;
			this.nativeCode = nativeCode;
		}

		public String getCode() {
			return code;
		}

		public String getNativeCode() {
			return nativeCode;
		}
	}

	/** 多个属性间OR关系的分隔符. */
	public static final String OR_SEPARATOR = "_OR_";

	private String fieldName;
	private Object value;
	private Operator operator;

	public SearchFilter(String fieldName, Operator operator, Object value) {
		this.fieldName = fieldName;
		this.value = value;
		this.operator = operator;
	}

    public String getFieldName() {
        return fieldName;
    }

    public Object getValue() {
        return value;
    }

    public Operator getOperator() {
        return operator;
    }
}
